package portal.web.servlets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.log4j.Logger;

import portal.facade.PortalComprasFacadeStateful;

@SuppressWarnings("serial")
public class ObtenerListaCarritoServlet extends HttpServlet {

	private static Logger logger = Logger.getLogger(ObtenerListaCarritoServlet.class);

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		processRequest(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		processRequest(req, resp);
	}

	private void processRequest(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		HttpSession session = req.getSession(true);
		PortalComprasFacadeStateful facadeStateful = (PortalComprasFacadeStateful) session.getAttribute("facadeStateful");
		
		req.setAttribute("listaCarrito", facadeStateful.getListaItems());

		req.getRequestDispatcher("/jsp/listaCarritoCompras.jsp").forward(req, resp);

	}
}
